#!/bin/bash

NDK_PLATFORM=linux-x86

#ABI=arm-linux-androideabi
#ABI_VER=4.4.3
#LDSCRIPT=armelf_linux_eabi.x

ABI=arm-eabi
ABI_VER=4.4.0
LDSCRIPT=armelf.x


PREBUILT=$ANDROID_NDK/toolchains/$ABI-$ABI_VER/prebuilt/$NDK_PLATFORM
PLATFORM=$ANDROID_NDK/platforms/android-5/arch-arm

./configure --target-os=linux \
	--arch=arm \
	--enable-version3 \
	--disable-gpl \
	--disable-nonfree \
	--disable-debug \
	--disable-stripping \
	--disable-ffmpeg \
	--disable-ffplay \
	--disable-ffserver \
	--disable-ffprobe \
	--disable-devices \
	--disable-protocols \
	--enable-protocol=file \
	--disable-encoders \
	--enable-encoder=mpeg4 \
	--enable-encoder=aac \
	--enable-muxers \
	--enable-avfilter \
	--enable-swscale \
	--disable-network \
	--disable-mpegaudio-hp \
	--disable-avdevice \
	--disable-postproc \
	--enable-cross-compile \
	--cc=$PREBUILT/bin/$ABI-gcc \
	--cross-prefix=$PREBUILT/bin/$ABI- \
	--nm=$PREBUILT/bin/$ABI-nm \
	--sysroot=$PLATFORM \
	--sysinclude=$PLATFORM/usr/include \
	--extra-cflags="-fPIC -DANDROID" \
	--extra-ldflags="-Wl,-T,$PREBUILT/$ABI/lib/ldscripts/$LDSCRIPT -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib $PREBUILT/lib/gcc/$ABI/$ABI_VER/crtbegin.o $PREBUILT/lib/gcc/$ABI/$ABI_VER/crtend.o -lc -lm -ldl"

# Disable the "restrict" keyword
sed 's/#define restrict restrict/#define restrict/g' config.h > config.h.new
mv config.h.new config.h

# Clear out the libavcodec/inverse.c
#sed 's/#include "libavutil/inverse.c"///commented out/g' config.h > config.h.new

